package com.example.system.entity;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.common.converter.DelFlagConverter;
import com.example.common.converter.SexConverter;
import com.example.common.converter.StatusConverter;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author 王鹤蒲
 * @since 2023-07-31
 */
@Data
@ExcelIgnoreUnannotated
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_user")
@ApiModel(value = "User对象", description = "")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("用户ID")
    @TableId(value = "user_id", type = IdType.AUTO)
    @ExcelIgnore
    private Integer userId;

    @ApiModelProperty("用户账号")
    @ExcelProperty(value="用户名称")
    private String userName;

    @ApiModelProperty("用户密码")
    @ExcelProperty(value="用户密码")
    private String password;

    @ApiModelProperty("用户昵称")
    @ExcelProperty(value="用户昵称")
    private String nickName;

    @ApiModelProperty("用户邮箱")
    @ExcelProperty(value="用户邮箱")
    private String email;

    @ApiModelProperty("手机号码")
    @ExcelProperty(value="手机号码")
    private String phonenumber;

    @ApiModelProperty("联系地址")
    @ExcelProperty(value="联系地址")
    private String address;

    @ApiModelProperty("用户性别（0男 1女 2未知）")
    @ExcelProperty(value="用户性别",converter= SexConverter.class)
    private String sex;

    @ApiModelProperty("头像地址")
    @ExcelProperty(value="头像地址")
    private String avatar;

    @ApiModelProperty("角色唯一标识")
    @ExcelProperty(value="角色唯一标识")
    private String role;

    @ApiModelProperty("帐号状态（0停用 1正常）")
    @ExcelProperty(value="帐号状态",converter= StatusConverter.class)
    private Integer status;

    @ApiModelProperty("删除标志（0代表存在 2代表删除）")
    @ExcelProperty(value="删除标志",converter= DelFlagConverter.class)
    private String delFlag;

    @ApiModelProperty("最后登录IP")
    @ExcelProperty(value="最后登录IP")
    private String loginIp;

    @ApiModelProperty("最后登录时间")
    @ExcelProperty(value="最后登录时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime loginDate;

    @ApiModelProperty("创建者")
    @ExcelProperty(value="创建者")
    private String createBy;

    @ApiModelProperty("创建时间")
    @ExcelProperty(value="创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty("更新者")
    @ExcelProperty(value="更新者")
    private String updateBy;

    @ApiModelProperty("更新时间")
    @ExcelProperty(value="更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime updateTime;

    @ApiModelProperty("备注")
    @ExcelProperty(value="备注")
    private String remark;


}
